<?php
namespace Admin\Controller;
class LinkController extends CommonController

{
       private $link;
    function __construct()
    {
        parent::__construct();
        $this->link=M("link");
    }

    public function index()
{
    $links=$this->link->order("sort_order")->select();
    $this->assign("links",$links);
    $this->display();
}
    public function do_add(){
        $this->link->create();
        $this->link->add();
        $this->success("新增成功","");
    }
    public function  do_edit(){
        $this->link->create();
        $this->link->save();
        $this->success("修改成功","");
    }
     public function del(){
         $id=I("get.id");
         $this->link->delete($id);
         $this->success("删除成功","");

     }
    public function destroy_checked()

    {
        dump($_POST);
       $delete_id=I("post.delete_id");
        foreach($delete_id as $id){
            $this->link->delete($id);

        }
        exit;
        $this->success("删除成功");

    }
    public function sort_order(){
        dump($_POST);
        exit;

      $sort_id=I("post.sort_id");
      $sort_order=I("post.sort_order");
        foreach ($sort_id as $key => $value) {
            $this->link->where("id=$value")->setField('sort_order', $sort_order[$key]);
        }
        $this->redirect('index');
    }






}